﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;


namespace Medical_Client
{
    public partial class MedicalLogin : Form
    {
        public bool isSuccess = false;
        private string strCmd = "";
        private const string USERINFO_TABLE = "operatorman";
        private FormMain FormMainDialog;

        public MedicalLogin()
        {
            InitializeComponent();
        }

        private void MedicalLogin_Load(object sender, EventArgs e)
        {

        }

        private void buttonCheck_Click(object sender, EventArgs e)
        {
            int[] iTemp=new int[20];
            int iNum;
            strCmd = "";
            strCmd = "select * from " + USERINFO_TABLE + " where no='" + textBoxUser.Text + "'" + " and password= '" + textBoxPass.Text + "' ;";
            DBManage dbm = new DBManage();
            dbm.CmdClear();
            dbm.CmdAppend(strCmd);
            if (dbm.iExistSearch("ok ", "用户名或密码错误", "数据库连接错误") == 1)
            {
                
                isSuccess = true;
                this.Hide();
                strCmd = "";
                strCmd = "select tab_no from " + "tab_User "+ " where user_no='" + textBoxUser.Text + "'" +  ";";
                dbm.CmdClear();
                dbm.CmdAppend(strCmd);
                iNum = dbm.multiSearch(iTemp);
                
                FormMainDialog = new FormMain();
                for (int i = 0; i < iNum; i++)
                {
                    FormMainDialog.tab_no[iTemp[i]] = true;
                }
                    FormMainDialog.ShowDialog();
                return;
            }
             return; 
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }

}